﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/formdiv.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/control.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/form.js?v=#{jsVersion}"></script>
<script type="text/javascript">

	var resizewindow= null;

	window.onresize = function(){
		var h = $(window).height();
		if(resizewindow!=h){
			sizewindow();
			resizewindow=h;
		}
	}

	function sizewindow(){
		var h = $(window).height();
		if(document.getElementById("mainbodybottonauto")){
			$('.managebottonadd').css({height:h-40});
		}
	}
	var language_js_lng_empty = "_{language_js_lng_empty}";
	var language_js_lngtitle_empty = "_{language_js_lngtitle_empty}";
	var language_js_url_err = "_{language_js_url_err}";
	var language_js_packname_err = "_{language_js_packname_err}";
	var language_js_add_ok = "_{language_js_add_ok}";
	var language_js_add_no = "_{language_js_add_no}";
	var lngcode_yes = "_{lngcode_yes}";
	var lngcode_no = "_{lngcode_no}";
	var iframename = "#{iframename}";
	iframename = iframename=='' ? "jerichotabiframe_0" : iframename;
	$(document).ready(function(){
	    var h = '#{iframeheightwindow}';
		$('.managebottonadd').css({height:h-40});
		var options = {

			beforeSubmit: formverify,

			success:saveResponse,
			resetForm: true
		}
		$('#lngadd').submit(function() {
			$(this).ajaxSubmit(options);
			return false;
		});
	})




	function formverify(formData) {
		var queryString = $.param(formData);
		var get=urlarray(queryString);
		if(get['lng']==""){
			document.lngadd.lng.focus();
			alert(language_js_lng_empty);
			return false;
		}
		if(get['lng'].match(/^[a-zA-Z]{1}[a-zA-Z]{1,19}$/ig)==null) {
			document.lngadd.lng.focus();
			alert(language_js_lng_empty);
			return false;
		}
		if(get['lngtitle']==""){
			document.lngadd.lngtitle.focus();
			alert(language_js_lngtitle_empty);
			return false;
		}
		if(get['ispack']=="1"){
			if(get['packname'].match(/^[a-zA-Z]{1,39}$/ig)==null) {
				document.lngadd.packname.focus();
				alert(language_js_packname_err);
				return false;
			}
		}
		if(get['url']!=""){

			if(get['url'].match(/^http:\/\/[a-zA-Z.0-9/_]+$/ig)==null) {
				document.lngadd.url.focus();
				alert(language_js_url_err);
				return false;
			}
		}
		parent.windowsdig('Loading', 'iframe:#{load}', '400px', '180px', 'iframe', false);
	}
	function saveResponse(options){
		parent.closeifram();
		var tab=document.getElementById("lngaddtab").value;
		if (options=='true'){
			if (tab=='true'){
				if(parent.frames[iframename].document.getElementById("pageinfo")){
					parent.frames[iframename].refresh('selectform','selectall','check_all');
				}
			}
			alert(language_js_add_ok);
		}else{
			alert(language_js_add_no+options);
		}
		if (tab=='true'){
			parent.onaletdoc()
		}
	}

	function checkcode(checktype){
		if(checktype=='lng'){
			var lngadd=document.getElementById("lngvalue").value;
			if(lngadd==""){
				return false;
			}
			var um=document.getElementById('codeerr');
			$.ajax({
				type: "POST",
				url: "#{codedb}",
				data: "codename="+lngadd,
				success: function(date){
					if (date=="false"){
						um.innerHTML="<font color=\"red\">"+lngcode_no+"</font>";
						$('#submitbotton').attr('disabled','true');
					}else{
						um.innerHTML="<font color=\"#1CB521\">"+lngcode_yes+"</font>";
						$('#submitbotton').attr('disabled','');
					}
				}
			});
		}else{
			var packname=document.getElementById("packname").value;
			if(packname==""){
				return false;
			}
			var um=document.getElementById('packnameerr');
			$.ajax({
				type: "POST",
				url: "#{codedb}?ispack=1",
				data: "packname="+packname,
				success: function(date){
					if (date=="false"){
						um.innerHTML="<font color=\"red\">"+lngcode_no+"</font>";
						$('#submitbotton').attr('disabled','true');
					}else{
						um.innerHTML="<font color=\"#1CB521\">"+lngcode_yes+"</font>";
						$('#submitbotton').attr('disabled','');
					}
				}
			});
		}

	}
</script>
</head>

<body>
<form name="lngadd" id="lngadd" method="post" action="#{ActionLink}">
<input type="hidden" name="tab" id="lngaddtab" value="#{tab}" />
<div id="mainbodybottonauto" class="managebottonadd">
	<div class="maindobycontent">
		<div class="suggestion">
			<span class="sugicon"><span class="strong colorgorning2">_{position_title}</span><span class="colorgorningage">_{language_add_mess}</span></span>
		</div>
		<div class="manageeditdiv">
			<div class="maneditcontent">
				<table class="formtable">
					<tr class="trstyle2">
						<td class="trtitle011">_{language_add_lng}</td>
						<td class="trtitle02"><input type="text" name="lng" id="lngvalue" size="25" maxlength="20" class="infoInput" onblur="checkcode('lng');"/> <span id="codeerr" class="cautiontitle">_{language_add_lng_mess}</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle011">_{language_add_lngtitle}</td>
						<td class="trtitle02"><input type="text" name="lngtitle" size="25" maxlength="50"  class="infoInput"/> <span class="cautiontitle">_{language_add_lngtitle_mess}</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{language_add_ispack}</td>
						<td class="trtitle02">
							<input type="radio" value="1" name="ispack" onclick="ondisplay('validatetextdiv','trstyle2 displaytrue')"/> _{open_botton_title}&nbsp;
							<input type="radio" value="0" name="ispack" checked="checked" onclick="ondisplay('validatetextdiv','trstyle2 displaynone')"/> _{close_botton_title}
							<span class="cautiontitle">_{language_add_ispack_mess}</span>
						</td>
					</tr>
					<tr class="trstyle2 displaynone" id="validatetextdiv">
						<td class="trtitle011">_{language_add_packname}</td>
						<td  class="trtitle02"><input type="text" name="packname" id="packname" size="25" maxlength="40" class="infoInput" onblur="checkcode('packname');"/> <span id="packnameerr" class="cautiontitle">_{language_add_packname_mess}</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{language_add_url}</td>
						<td class="trtitle02"><input type="text" name="url" size="50" maxlength="100"  class="infoInput"/> <span class="cautiontitle">_{language_add_url_mess}</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">_{iswap_title}</td>
						<td class="trtitle02">
							<input type="radio" value="1" name="iswap"/> _{open_botton_title}&nbsp;
							<input type="radio" value="0" name="iswap" checked="checked"/> _{close_botton_title}
							<span class="cautiontitle">_{iswap_title_mess}</span>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<div id="downbotton">
	<div id="subbotton">
		<table border="0" width="100%">
			<tr>
				<td id="right"><input type="submit" id="submitbotton" name="Submit" value="_{botton_add}" class="buttonface" /></td>
				<td id="left" class="padding-left5"><input type="button" name="cancel" onClick="javascript:parent.onaletdoc();" value="_{botton_add_reset}" class="buttonface" /></td>
			</tr>
		</table>
	</div>
</div>
</form>
</body>

</html>